﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using YW.Common;
using LTP.Accounts.Bus;
namespace YW.Web.HYXT.yw_jfbgjl
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					Guid yw_id=new Guid(Request.Params["id"]);
					ShowInfo(yw_id);
				}
			}
		}
			
	private void ShowInfo(Guid yw_id)
	{
		YW.BLL.HYXT.yw_jfbgjl bll=new YW.BLL.HYXT.yw_jfbgjl();
		YW.Model.HYXT.yw_jfbgjl model=bll.GetModel(yw_id);
		this.lblyw_id.Text=model.yw_id.ToString();
		this.txtEMPI.Text=model.EMPI;
		this.txtbgsj.Text=model.bgsj.ToString();
		this.txtbgjf.Text=model.bgjf.ToString();
		this.txtbglx.Text=model.bglx;
		this.txtywlx.Text=model.ywlx;
		this.txtxgdjh.Text=model.xgdjh;
		this.txtyypzbzj.Text=model.yypzbzj;
		this.txtkh.Text=model.kh;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtEMPI.Text.Trim().Length==0)
			{
				strErr+="EMPI不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtbgsj.Text))
			{
				strErr+="变更时间格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtbgjf.Text))
			{
				strErr+="变更积分格式错误！\\n";	
			}
			if(this.txtbglx.Text.Trim().Length==0)
			{
				strErr+="变更类型不能为空！\\n";	
			}
			if(this.txtywlx.Text.Trim().Length==0)
			{
				strErr+="业务类型不能为空！\\n";	
			}
			if(this.txtxgdjh.Text.Trim().Length==0)
			{
				strErr+="相关单据号不能为空！\\n";	
			}
			if(this.txtyypzbzj.Text.Trim().Length==0)
			{
				strErr+="用友凭证表主键不能为空！\\n";	
			}
			if(this.txtkh.Text.Trim().Length==0)
			{
				strErr+="卡号不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			Guid yw_id= new Guid(this.lblyw_id.Text);
			string EMPI=this.txtEMPI.Text;
			DateTime bgsj=DateTime.Parse(this.txtbgsj.Text);
			decimal bgjf=decimal.Parse(this.txtbgjf.Text);
			string bglx=this.txtbglx.Text;
			string ywlx=this.txtywlx.Text;
			string xgdjh=this.txtxgdjh.Text;
			string yypzbzj=this.txtyypzbzj.Text;
			string kh=this.txtkh.Text;


			YW.Model.HYXT.yw_jfbgjl model=new YW.Model.HYXT.yw_jfbgjl();
			model.yw_id=yw_id;
			model.EMPI=EMPI;
			model.bgsj=bgsj;
			model.bgjf=bgjf;
			model.bglx=bglx;
			model.ywlx=ywlx;
			model.xgdjh=xgdjh;
			model.yypzbzj=yypzbzj;
			model.kh=kh;

			YW.BLL.HYXT.yw_jfbgjl bll=new YW.BLL.HYXT.yw_jfbgjl();
			bll.Update(model);
			YW.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
